<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Language" content="zh-CN"><link href="stylesheet.css" media="all" rel="stylesheet" type="text/css">
<title>ALTER GROUP</title>
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head><body class="REFENTRY">
<div>
<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><th colspan="5" align="center" valign="bottom">PostgreSQL 8.2.3 中文文档</th></tr>
<tr><td width="10%" align="left" valign="top"><a href="sql-alterfunction.html" accesskey="P">后退</a></td><td width="10%" align="left" valign="top"><a href="sql-alterfunction.html">快退</a></td><td width="60%" align="center" valign="bottom"></td><td width="10%" align="right" valign="top"><a href="sql-alterindex.html">快进</a></td><td width="10%" align="right" valign="top"><a href="sql-alterindex.html" accesskey="N">前进</a></td></tr>
</table>
<hr align="LEFT" width="100%"></div>
<h1><a name="SQL-ALTERGROUP"></a>ALTER GROUP</h1>
<div class="REFNAMEDIV"><a name="AEN44152"></a><h2>名称</h2>ALTER GROUP&nbsp;--&nbsp;修改角色名或者成员关系</div>
<a name="AEN44155"></a>
<div class="REFSYNOPSISDIV"><a name="AEN44157"></a><h2>语法</h2>
<pre class="SYNOPSIS">ALTER GROUP <tt class="REPLACEABLE"><i>groupname</i></tt> ADD USER <tt class="REPLACEABLE"><i>username</i></tt> [, ... ]
ALTER GROUP <tt class="REPLACEABLE"><i>groupname</i></tt> DROP USER <tt class="REPLACEABLE"><i>username</i></tt> [, ... ]

ALTER GROUP <tt class="REPLACEABLE"><i>groupname</i></tt> RENAME TO <tt class="REPLACEABLE"><i>newname</i></tt></pre>
</div>
<div class="REFSECT1"><a name="AEN44165"></a><h2>描述</h2>
<p><tt class="COMMAND">ALTER GROUP</tt> 修改一个用户组的属性。这是一条过时的命令，不过出于向后兼容的原因还被接受，因为组(及用户)都已经被更一般的概念：角色，给代替了。</p>
<p>头两个形式从组中增加或者删除用户。任何角色都可以当作"用户"或者"组"来做这个事情。这个变体实际上等效于给命名为"组"的角色名赋予或者撤销成员关系；因此，做这个事情的比较好的方法是 <a href="sql-grant.html"><i>GRANT</i></a> 或 <a href="sql-revoke.html"><i>REVOKE</i></a> 。</p>
<p>第三种变体修改一个组的名字。它完全等效于用 <a href="sql-alterrole.html"><i>ALTER ROLE</i></a> 重命名角色。</p>
</div>
<div class="REFSECT1"><a name="AEN44177"></a><h2>参数</h2>
<div class="VARIABLELIST">
<dl>
<dt><tt class="REPLACEABLE"><i>groupname</i></tt></dt>
<dd><p>要更改的组(角色)名称</p></dd>
<dt><tt class="REPLACEABLE"><i>username</i></tt></dt>
<dd><p>准备向组(角色)中增加或从组(角色)中删除的用户名(必须已经存在)。<tt class="COMMAND">ALTER GROUP</tt> 并不创建或删除用户。</p></dd>
<dt><tt class="REPLACEABLE"><i>newname</i></tt></dt>
<dd><p>组的新名字</p></dd>
</dl>
</div>
</div>
<div class="REFSECT1"><a name="AEN44196"></a><h2>例子</h2>
<p>向组中增加用户：</p>
<pre class="PROGRAMLISTING">ALTER GROUP staff ADD USER karl, john;</pre>
<p>从组中删除用户：</p>
<pre class="PROGRAMLISTING">ALTER GROUP workers DROP USER beth;</pre>
</div>
<div class="REFSECT1"><a name="AEN44201"></a><h2>兼容性</h2>
<p>SQL 标准里没有 <tt class="COMMAND">ALTER GROUP</tt> 语句。</p>
</div>
<div class="REFSECT1"><a name="AEN44205"></a><h2>又见</h2><a href="sql-grant.html"><i>GRANT</i></a>, <a href="sql-revoke.html"><i>REVOKE</i></a>, <a href="sql-alterrole.html"><i>ALTER ROLE</i></a></div>
<div>
<hr align="LEFT" width="100%">
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="33%" align="left" valign="top"><a href="sql-alterfunction.html" accesskey="P">后退</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">首页</a></td><td width="33%" align="right" valign="top"><a href="sql-alterindex.html" accesskey="N">前进</a></td></tr>
<tr><td width="33%" align="left" valign="top">ALTER FUNCTION</td><td width="34%" align="center" valign="top"><a href="sql-commands.html" accesskey="U">上一级</a></td><td width="33%" align="right" valign="top">ALTER INDEX</td></tr>
</table>
</div>
</body></html>